﻿#include <time.h>
#include <d3d9.h>
#include <d3dx9.h>
#include "MarioManager.h"
#include "Surface.h"
#include "Resource.h"


/**--------------------------------------------------------
*Description : Constructor
*Method name : MarioManager
*Parameters :  HINSTANCE hInstance, LPWSTR Name, int Mode, int IsFullScreen, int FrameRate
*Return value :
--------------------------------------------------------**/
MarioManager::MarioManager(HINSTANCE hInstance, LPWSTR Name, int Mode, int IsFullScreen, int FrameRate):
Game(hInstance,Name,Mode,IsFullScreen, FrameRate)
{
	//TODO: Init game
	
	quadTree = NULL;
	//scoreList = new list<Score*>;
}


/**--------------------------------------------------------
*Description : Destructor
*Method name : ~MarioManager
*Parameters :  
*Return value :
--------------------------------------------------------**/
MarioManager::~MarioManager()
{
	//TODO: Release game
	
	 
	if (mapManager)
	{
		delete mapManager;
	}


	delete camera;
	delete quadTree;

	 
	for (int i = 0; i < 4; i++)
	{
		delete scoreArr[i];
	}
	for (int i = 0; i < 2; i++)
	{
		delete infoArr[i];
	}
	

	delete dxAudio;

	delete backgroundSound;
	delete bonusRiseSound;
	delete brickBreakSound; 
	delete bumpSound;
	delete coinSound; 
	delete deathSound;
	delete fireballSound; 
	delete gameOverSound;
	delete jumpSound; 
	delete kickSound; 
	delete lifeSound; 
	delete mipSound; 
	delete pipeWarpSound; 
	delete powerupSound; 
	delete startGameSound; 
	delete winGameSound;

}


/**--------------------------------------------------------
*Description : Load tai nguyen 
*Method name : LoadResources
*Parameters :  LPDIRECT3DDEVICE9 d3ddv
*Return value :void
--------------------------------------------------------**/
void MarioManager::LoadResources(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 BackBuffer)
{
	HRESULT res = D3DXCreateSprite(d3ddv, &_spriteHandler);
	//TODO: Load resource game	
	ResourceMng *rm = ResourceMng::GetInst(d3ddv, BackBuffer);

	num_Score = 0;
	num_Life = 3;
	num_Coin = 0;
	count_Time = 400;

	map_Current = 1;
	submap = 0;

	//---------LOAD MAP, CAMERA--------//
	camera = new Camera();
	quadTree = new QuadTree(0, 0, 3400, 0);
	mapManager = new Map(d3ddv, BackBuffer, _spriteHandler, this);
	//map1->LoadMapFromFile("..\\Resources\\Map\\loadmap.txt");
	////map_list = map1->GetObjects();
	//map_list = map1->GetAllObjects(quadTree, this);

	//fix map
	mapManager->LoadMap("..\\Resources\\Map\\loadmap.txt", quadTree, this);

	pointMenu = new Sprite(_spriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\Star.png"), 0, 0);
	 
	/*
	info score
	info coin
	info number life
	info time
	info world1
	info world2
	*/
	scoreArr[SCORE] = new Score(d3ddv, BackBuffer, _spriteHandler, 100, 50);			 
	scoreArr[COIN] = new Score(d3ddv, BackBuffer, _spriteHandler, 200, 50);			 
	scoreArr[NUMBER_LIFE] = new Score(d3ddv, BackBuffer, _spriteHandler, 450, 310);		 
	scoreArr[NUMBER_LIFE]->Update(num_Life);
	scoreArr[TIME] = new Score(d3ddv, BackBuffer, _spriteHandler, 700, 50);			 
	scoreArr[WORLD1] = new Score(d3ddv, BackBuffer, _spriteHandler, 500, 50);			 
	scoreArr[WORLD1]->Update(map_Current);
	scoreArr[WORLD2] = new Score(d3ddv, BackBuffer, _spriteHandler, 450, 250);			 
	scoreArr[WORLD2]->Update(map_Current);

	/*
	info num life
	info coin
	info world
	info time
	info result
	*/
	infoArr[0] = new Info(new Sprite(_spriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\infomario.png"), 0, 0), 50, 20);	
	infoArr[1] = new Info(new Sprite(_spriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\infocoin.png"), 0, 0), 150, 50);	
	infoArr[2] = new Info(new Sprite(_spriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\infoworld.png"), 0, 0), 500, 20);	
	infoArr[3] = new Info(new Sprite(_spriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\infotime.png"), 0, 0), 650, 20);	
	infoArr[4] = new Info(new Sprite(_spriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\inforesult.png"), 0, 0), 370, 300);
	infoArr[5] = new Info(new Sprite(_spriteHandler, ResourceMng::GetInst(d3ddv, BackBuffer)->GetTexture(L"..\\Resources\\Images\\infoworld.png"), 0, 0), 370, 250);

	reset_Time = 0;

	timeChangeMap = 30;

	game_State = GS_MENU;
	yPointMenu = 320;
	xPointMenu = 320;
	 
	
	

	//load bounce wave file
	dxAudio = new DxAudio();
	dxAudio->Init_DirectSound(_hWnd);

	backgroundSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\Background.wav");
	bonusRiseSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\BonusRise.wav");
	brickBreakSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\BrickBreaked.wav");
	bumpSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\Bump.wav");
	coinSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\Coin.wav");
	deathSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\Death.wav");
	fireballSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\Fireball.wav");
	gameOverSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\GameOver.wav");
	jumpSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\Jump.wav");
	kickSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\Kick.wav");
	lifeSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\Life.wav");
	mipSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\Mip.wav");
	pipeWarpSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\PipeWarp.wav");
	powerupSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\PowerUp.wav");
	startGameSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\StartGame.wav");
	winGameSound = dxAudio->LoadSound(L"..\\Resources\\Audio\\WinStage.wav");


	 
}


/**--------------------------------------------------------
*Description : Render Frame
*Method name : RenderFrame
*Parameters :  LPDIRECT3DDEVICE9 d3ddv, int t
*Return value :void
--------------------------------------------------------**/
void MarioManager::RenderFrame(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 BackBuffer, int t)
{
	 
	//TODO: DRAW---------------------------------------------------------
	
  
	_spriteHandler->Begin(D3DXSPRITE_ALPHABLEND);

	switch (game_State)
	{
	case GS_MENU:
		d3ddv->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0,0);
		ResourceMng::GetInst(d3ddv, BackBuffer)->GetSurface(L"..\\Resources\\Images\\Menu.jpg")->Draw(NULL, NULL ); //chu y ham Draw co 2 tham so NULL
		pointMenu->Render(xPointMenu, yPointMenu);
		break;

	case GS_ABOUT:
		d3ddv->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0,0);
		ResourceMng::GetInst(d3ddv, BackBuffer)->GetSurface(L"..\\Resources\\Images\\About.jpg")->Draw(NULL, NULL ); //chu y ham Draw co 2 tham so NULL
		//pointMenu->Render(xPointMenu, yPointMenu);
		break;

	case GS_GAMEOVER:
		d3ddv->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0,0);
		ResourceMng::GetInst(d3ddv, BackBuffer)->GetSurface(L"..\\Resources\\Images\\GameOver.jpg")->Draw(NULL, NULL ); //chu y ham Draw co 2 tham so NULL
		//pointMenu->Render(xPointMenu, yPointMenu);
		break;

	case GS_SUB_STAGE:
		break;

	case GS_RETURN_STAGE:
		break;

	case GS_REPLAY:
	case GS_NEXT_STAGE:
		d3ddv->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0,0);
		//ResourceMng::GetInst(d3ddv, BackBuffer)->GetSurface(L"..\\Resources\\Images\\transfermap.png")->Draw(NULL, NULL ); //chu y ham Draw co 2 tham so NULL
		ResourceMng::GetInst(d3ddv, BackBuffer)->GetSurface(L"..\\Resources\\Images\\background.jpg")->Draw(NULL, NULL ); //chu y ham Draw co 2 tham so NULL
		
		scoreArr[SCORE]->Render(camera->GetCameraRect());
		scoreArr[COIN]->Render(camera->GetCameraRect());
		scoreArr[NUMBER_LIFE]->Render(camera->GetCameraRect());
		scoreArr[WORLD1]->Render(camera->GetCameraRect());
		scoreArr[WORLD2]->Render(camera->GetCameraRect());

		infoArr[0]->Render(camera->GetCameraRect());
		infoArr[1]->Render(camera->GetCameraRect());
		infoArr[2]->Render(camera->GetCameraRect());
		infoArr[3]->Render(camera->GetCameraRect());
		infoArr[4]->Render(camera->GetCameraRect());
		infoArr[5]->Render(camera->GetCameraRect());
		//pointMenu->Render(xPointMenu, yPointMenu);
		break;

	case GS_LOAD:
		d3ddv->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0,0);
		break;

	case GS_PLAYING:
		ResourceMng::GetInst(d3ddv, BackBuffer)->GetSurface(L"..\\Resources\\Images\\background.jpg")->Draw(NULL, NULL ); //chu y ham Draw co 2 tham so NULL
		_spriteHandler->SetTransform(&(camera->GetMatrix()));
		// Texture

		Object* obj;
		list<Object*>::iterator i;
		Score* tempScore;
		list<Score*>::iterator iScore;
		
		for(i = dynamicObjs.begin(); i != dynamicObjs.end(); i++)
		{
			obj=*i;
			if((obj->GetX() > camera->GetCameraRect().left - _ScreenWidth + 300) && (obj->GetX() < camera->GetCameraRect().left + _ScreenWidth + 100))
				obj->Render();
		}

		for(i = staticObjs.begin(); i != staticObjs.end(); i++)
		{
			obj = *i;
			if((obj->GetX() > camera->GetCameraRect().left - _ScreenWidth + 300) && (obj->GetX() < camera->GetCameraRect().left + _ScreenWidth + 100))
				obj->Render();
		}
		
		for (iScore = scoreList.begin(); iScore != scoreList.end(); iScore++)
		{
			tempScore = *iScore;
			tempScore->Render();
		}
		 
		 
		scoreArr[SCORE]->Render(camera->GetCameraRect());
		scoreArr[COIN]->Render(camera->GetCameraRect());
		scoreArr[TIME]->Render(camera->GetCameraRect());
		scoreArr[WORLD1]->Render(camera->GetCameraRect());

		infoArr[0]->Render(camera->GetCameraRect());
		infoArr[1]->Render(camera->GetCameraRect());
		infoArr[2]->Render(camera->GetCameraRect());
		infoArr[3]->Render(camera->GetCameraRect());
		break;

	
	}

	_spriteHandler->End();
}


/**--------------------------------------------------------
*Description : Kiem tra phim nhan
*Method name : ProcessInput
*Parameters :  LPDIRECT3DDEVICE9 d3ddv, int t
*Return value :void
--------------------------------------------------------**/
void MarioManager::ProcessInput(LPDIRECT3DDEVICE9 d3ddv, int t)
{
	////printf("FPS: %f", this->GetFPS());
 
	switch (game_State)
	{
	case GS_MENU:
		{
			int temp = input->GetKeyDown();
			switch (temp)
			{
			case DIK_DOWN:
				yPointMenu += 50;
				if (yPointMenu > 470)
				{
					yPointMenu = 320;
				}
				dxAudio->PlaySoundW(fireballSound);
				break;

			case DIK_UP:
				yPointMenu -= 50;
				if (yPointMenu < 320)
				{
					yPointMenu = 470;
				}
				dxAudio->PlaySoundW(fireballSound);
				break;

			case DIK_RETURN:
				dxAudio->PlaySoundW(fireballSound);
				if (yPointMenu == 320)
				{
					num_Coin = 0;
					num_Life = 3;
					num_Score = 0;
					scoreArr[NUMBER_LIFE]->Update(num_Life);
					scoreArr[COIN]->Update(num_Coin);
					scoreArr[SCORE]->Update(num_Score);

					map_Current = 1;
					ChangeMap(map_Current);
					//ChangeState(GS_PLAYING);
					
				}
				else if(yPointMenu == 370)
				{
					ChangeState(GS_LOAD);
				}
				else if(yPointMenu == 420)
				{
					ChangeState(GS_ABOUT);
				}
				else if (yPointMenu == 470)
				{
					//PostQuitMessage(0);
					trace(L"Main game is ended!");
					PostMessage(_hWnd,WM_QUIT,0,0);
				}
				break;

			}
		}
		break;

	case GS_PLAYING:
		{
			if (input->IsKeyDown(DIK_ESCAPE))
			{
				 
				ChangeState(GS_MENU);
			}
			 
			if (input->IsKeyDown(DIK_S))
			{
				mapManager->numScore = num_Score;
				mapManager->numLife = num_Life;
				mapManager->numCoin = num_Coin;

				mapManager->SaveMap("..\\Resources\\Map\\savemapfix.txt", quadTree, this);
				dxAudio->PlaySoundW(fireballSound);
			}
		}

		 
		break;

	case GS_ABOUT:
		if (input->IsKeyDown(DIK_ESCAPE))
		{
			ChangeState(GS_MENU);
		}
		break;

	case GS_GAMEOVER:
		if (input->IsKeyDown(DIK_ESCAPE))
		{
			ChangeState(GS_MENU);
		}
		break;
	}
}



 
void MarioManager::Update(LPDIRECT3DDEVICE9 d3ddv, LPDIRECT3DSURFACE9 BackBuffer, int t)
{
	//ProcessInput();
	switch (game_State)
	{
	case GS_MENU:

		break;
	case GS_ABOUT:

		break;
	case GS_NEXT_STAGE:				//Khi đổi màn
		reset_Time += t;
		if (reset_Time > 100)
		{
			reset_Time -= 100;
			timeChangeMap--;
			if (timeChangeMap <= 0)
			{

				map_Current++;
				scoreArr[WORLD1]->Update(map_Current);
				scoreArr[WORLD2]->Update(map_Current);
				ChangeMap(map_Current);
			}
		}
		//ChangeMap(map_Current+1);
		break;

	case GS_RETURN_STAGE:				//Khi đổi màn
		reset_Time += t;
		if (reset_Time > 100)
		{
			reset_Time -= 100;
			timeChangeMap--;
			if (timeChangeMap <= 0)
			{

				
				ChangeMap(map_Current);
			}
		}
		//ChangeMap(map_Current+1);
		break;

	case GS_REPLAY:				//choi lai map
		reset_Time += t;
		if (reset_Time > 100)
		{
			reset_Time -= 100;
			timeChangeMap--;
			if (timeChangeMap <= 0)
			{
				ChangeMap(map_Current);
			}
		}
		//ChangeMap(map_Current+1);
		break;

	case GS_SUB_STAGE:				//choi map phu
		reset_Time += t;
		if (reset_Time > 100)
		{
			reset_Time -= 100;
			timeChangeMap--;
			if (timeChangeMap <= 0)
			{
				submap = map_Current;
				ChangeSubMap(submap);
			}
		}
		break;
		
	case GS_PLAYING:

		reset_Time += t;
		if (reset_Time > 100)
		{
			reset_Time -= 100;//500;
			count_Time--;
			scoreArr[TIME]->Update(count_Time);
		}
		 
		


		Object* obj;
		list<Object*>::iterator i;
		Score* tempScore;
		list<Score*>::iterator iScore;

		for(i = staticObjs.begin(); i != staticObjs.end(); i++)
		{
			obj = *i;
			if (obj->object_State == 0) //TRANG THAI REMOVE CUA OBJECT
			{
				quadTree->DeleteObj(obj, true);
			}
		}
		for(i = dynamicObjs.begin(); i != dynamicObjs.end(); i++)
		{
			obj=*i;
			if (obj->object_State == 0)	//TRANG THAI REMOVE CUA OBJECT
			{
				quadTree->DeleteObj(obj, false);
			}

		}

		
		staticObjs.clear();
		dynamicObjs.clear();

		//CHI HIEN CAC DOI TUONG TRONG KHUNG CAMERA
		quadTree->GetObjectsFromCamera(camera->GetCameraRect(), &staticObjs, &dynamicObjs);

		//Cập nhật. Chỉ cập nhật những đối tượng ở trước Camera một khoảng  và sau camera một khoảng 
		//camera->Update(TPF,quadTree);
		for(i = staticObjs.begin(); i != staticObjs.end(); i++)
		{
			obj = *i;
			//if((obj->GetX() > camera->GetCameraRect().left - 10) && (obj->GetX() < camera->GetCameraRect().left + _ScreenWidth + 10))
			if((obj->GetX() > camera->GetCameraRect().left - _ScreenWidth + 300) && (obj->GetX() < camera->GetCameraRect().left + _ScreenWidth + 100))
				obj->Update(&staticObjs,&dynamicObjs,input,t);
		}
		for(i = dynamicObjs.begin(); i != dynamicObjs.end(); i++)
		{
			obj=*i;
			if (obj->GetID() != 2)		//khong phai mario
			{
				if((obj->GetX() > camera->GetCameraRect().left - _ScreenWidth + 300) && (obj->GetX() < camera->GetCameraRect().left + _ScreenWidth + 100))
					obj->Update(&staticObjs,&dynamicObjs,input,t);
			}
			else
			{
				obj->Update(&staticObjs, &dynamicObjs, input, t);
				camera->Update(obj->GetPosition());
			}

		}
		//quadTree->Update(dynamicObjs);

		//HIEN THI DIEM KHI DAP CHET QUAI, AN DIEM
		scoreRemoveList.clear();
		for (iScore = scoreList.begin(); iScore != scoreList.end(); iScore++)
		{
			tempScore = *iScore;
			tempScore->Update(&staticObjs,&dynamicObjs,input,t);
			if (tempScore->object_State == IS_IDLE) //die
			{
				delete tempScore;
				scoreRemoveList.push_back(tempScore);
			}
		}
		for (iScore = scoreRemoveList.begin(); iScore != scoreRemoveList.end(); iScore++)
		{
			scoreList.remove(*iScore);
		}

		
		 

		//_score->Update(&staticObjs,&dynamicObjs,input,t);

		//audio->Update();
		/*for (int i = 0; i < map_list.size(); i++)
		{
		map_list[i]->Update(_ScreenWidth, _ScreenHeight, t);
		}*/
		//_mario->Update(_ScreenWidth, _ScreenHeight, t, CollisionObjectList, input);

		////_mario->Update(&staticObjs, &dynamicObjs, input, t);
		//camera->Update(_mario->GetPosition());

		//if (Collision::RectVsRect(_mario->GetBond(), _tur->GetBond()))
		//{
		//	//_mario->Jump();
		//	dxAudio->PlaySound(bonusRiseSound);
		//	//_score->Update(100);
		//}

		break;
	}


}

void MarioManager::InfoScore(int score, int x, int y)
{
	num_Score += score;
	Score* _tempScore = new Score(d3d->GetDevice(), d3d->GetBackBuffer(), _spriteHandler, x, y);
	_tempScore->score = score;
	scoreList.push_back(_tempScore);
}

void MarioManager::ChangeState(int state)
{
	game_State = state;
	switch (game_State)
	{
	case GS_MENU:
		xPointMenu = 320;
		yPointMenu = 320;
		break;

	case GS_PLAYING:
		count_Time = 400;
		reset_Time = 0;

		xPointMenu = 320;
		yPointMenu = 320;
		break;

	case GS_LOAD:
		delete quadTree;
		quadTree = new QuadTree(0, 0, 3400, 0);
		//map1->LoadMapFromFile("..\\Resources\\Map\\savemap.txt");
		mapManager->LoadMap("..\\Resources\\Map\\savemapfix.txt", quadTree, this);

		num_Score = mapManager->numScore;
		num_Life = mapManager->numLife;
		num_Coin = mapManager->numCoin;

		xPointMenu = 320;
		yPointMenu = 320;
		ChangeState(GS_PLAYING);
		break;

	case GS_ABOUT:

		break;

	case GS_GAMEOVER:

		break;

	case GS_NEXT_STAGE:
		reset_Time = 0;
		timeChangeMap = 30;
		break;

	case GS_RETURN_STAGE:
		reset_Time = 0;
		timeChangeMap = 10;
		break;

	case GS_REPLAY:
		reset_Time = 0;
		timeChangeMap = 30;
		break;

	case GS_SUB_STAGE:
		reset_Time = 0;
		timeChangeMap = 10;
		/*submap = map_Current;
		ChangeSubMap(submap);*/
		break;

	}
}

void MarioManager::ChangeMap(int _map)
{
	/*if (issubmap == true)
	{
		mapManager->isLoadSubMap = true;
		issubmap = false;
	}*/
	 
	map_Current = _map;
	switch(map_Current)
	{
	case 1:
		delete quadTree;
		quadTree = new QuadTree(0, 0, 3400, 0);
		mapManager->LoadMap("..\\Resources\\Map\\loadmap.txt", quadTree, this);
		//mapManager->isLoadSubMap = false;
		staticObjs.clear();
		dynamicObjs.clear();
		break;

	case 2:
		delete quadTree;
		quadTree = new QuadTree(0, 0, 3400, 0);
		mapManager->LoadMap("..\\Resources\\Map\\loadmap2.txt", quadTree, this);
		//mapManager->isLoadSubMap = false;


		staticObjs.clear();
		dynamicObjs.clear();
		break;

	case 3:
		delete quadTree;
		quadTree = new QuadTree(0, 0, 3400, 0);
		mapManager->LoadMap("..\\Resources\\Map\\loadmap3.txt", quadTree, this);
		//mapManager->isLoadSubMap = false;
		staticObjs.clear();
		dynamicObjs.clear();
		break;
	}
	 
	
	mapManager->isLoadSubMap = false;

	if(map_Current < 4)
		ChangeState(GS_PLAYING);
	else 
		ChangeState(GS_ABOUT);

}


void MarioManager::ChangeSubMap(int _submap)
{

	//issubmap = true;

	submap = _submap;
	switch(submap)
	{
	case 1:
		delete quadTree;
		quadTree = new QuadTree(0, 0, 3400, 0);
		mapManager->LoadMap("..\\Resources\\Map\\submap1.txt", quadTree, this);
		//mapManager->isLoadSubMap = true;
		staticObjs.clear();
		dynamicObjs.clear();
		break;

	case 2:
		delete quadTree;
		quadTree = new QuadTree(0, 0, 3400, 0);
		mapManager->LoadMap("..\\Resources\\Map\\submap2.txt", quadTree, this);
		//mapManager->isLoadSubMap = true;
		staticObjs.clear();
		dynamicObjs.clear();
		break;

	case 3:
		delete quadTree;
		quadTree = new QuadTree(0, 0, 3400, 0);
		mapManager->LoadMap("..\\Resources\\Map\\submap3.txt", quadTree, this);
		//mapManager->isLoadSubMap = true;
		staticObjs.clear();
		dynamicObjs.clear();
		break;
	}

	mapManager->isLoadSubMap = true;
	

	if(submap < 4)
		ChangeState(GS_PLAYING);
	else 
		ChangeState(GS_ABOUT);

}